package com.example.lenovo.demo.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.lenovo.demo.DebarkActivity;
import com.example.lenovo.demo.FeedBackActivity;
import com.example.lenovo.demo.MessageCenterActivity;
import com.example.lenovo.demo.R;
import com.example.lenovo.demo.SetActivity;

/**
 * Created by Administrator on 2017/1/9.
 *我的界面
 */

public class MyFragment extends Fragment {

    Activity mActivity;
     private Toolbar toolbar;
   private ImageView iv_register;
    //铃铛
    private ImageView iv_bell;
//  我的收藏——text
    private TextView my_collect;
    //收藏——img
    private ImageView  my_start;
    //订单
    private TextView my_index_tv;
    private ImageView my_index_img;
    //意见
    private ImageView my_message_img;
    private TextView my_message;
    //设置
    private ImageView my_set_img;
    private TextView my_set_tv;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mActivity = getActivity();

        View view = inflater.inflate(R.layout.fragment_my,container,false);
        Log.e("msg","aaa");
        toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        toolbar.inflateMenu(R.menu.mymenu);
        setHasOptionsMenu(true);
        //选项菜单的点击
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case  R.id.my_menu1:
                        Toast.makeText(mActivity, "先登录", Toast.LENGTH_SHORT).show();
                        startActivity(new Intent(getActivity(),DebarkActivity.class));
                        break;
                    case R.id.my_menu2:
                        startActivity(new Intent(getActivity(),DebarkActivity.class));
                        break;
                    case R.id.my_menu3:
                        startActivity(new Intent(getActivity(),DebarkActivity.class));
                        break;

                }
                return true;
            }
        });

        //未登录点击
        iv_register = (ImageView) view.findViewById(R.id.iv_register);
        iv_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(),DebarkActivity.class));
            }
        });

        //铃铛点击
         iv_bell = (ImageView) view.findViewById(R.id.iv_bell);
        iv_bell.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
             startActivity(new Intent(getActivity(), MessageCenterActivity.class));
            }
        });

        //我的收藏
        my_collect = (TextView) view.findViewById(R.id.my_collect);
        my_collect .setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(),DebarkActivity.class));
            }
        });
        my_start = (ImageView) view.findViewById(R.id.my_start);
        my_start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(),DebarkActivity.class));
            }
        });

        //订单
        my_index_tv = (TextView) view.findViewById(R.id.my_index_tv);
       my_index_img = (ImageView) view.findViewById(R.id.my_index_img);

        my_index_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(),DebarkActivity.class));
            }
        });
        my_index_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(),DebarkActivity.class));
            }
        });

        //意见
        my_message_img= (ImageView) view.findViewById(R.id.my_message_img);
        my_message = (TextView) view.findViewById(R.id.my_message);
        my_message_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), FeedBackActivity.class));
            }
        });
        my_message.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), FeedBackActivity.class));
            }
        });


        //设置
        my_set_tv = (TextView) view.findViewById(R.id.my_set_tv);
        my_set_img = (ImageView) view.findViewById(R.id.my_set_img);
        my_set_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), SetActivity.class));
            }
        });
        my_set_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(),SetActivity.class));
            }
        });


        return view;
    }


}
